<template>
    <div class="rank">
        <div class="rank-lisk" v-for="item in topList" :key="item.title" >
          
          <div class="">
          <div class="rank-list" v-for="itemList in item.list" :key="itemList.topId" @click="selectRankListDetail(itemList)">
            
            <div class="item">
              <h4>{{ itemList.label }}</h4>
              <ul>
                <li v-for="(musicItem,i) in itemList.song" :key="musicItem.songId" >
                  <span>{{ i+1 }}.{{ musicItem.title }} - {{musicItem.singerName}}</span>
                </li>
              </ul>
            </div>
            <div class="item">
              <img :src="itemList.picUrl" alt="">  
            </div> 
            </div>
          </div>
        </div>
    </div>
</template>
<script>
import axios from 'axios';
export default {
    data(){
      return{
        topList:[]
      }
    },
    created(){
        this.getTopList()
    },
    methods:{
        getTopList(){
            axios.get("/jsososo/top/category",{
                params:{
                    showDetail:1
                }
            })
            .then(res => {
                console.log(res.data.data)
                this.topList=res.data.data
            })
            .catch(err => {
                console.error(err); 
            })
        },
        selectRankListDetail(item){
            const id = item.topId;
            this.$router.push({path:`/ranklistdetail/${id}`})
        },
    },

}
</script>

/**样式定义 */
<style scoped>
.rank-list{
  display: -webkit-box;
  -webkit-box-align: center;
  background:  #faebd7;
  border-radius: 10px;/**圆角 */
  width: 90%;
  margin: 5%;
}
.item{
  width:50%;
  text-align: left;
  margin-left: 15px;
}
.item>h4{
  font-size: 18px;
  margin-top: 4px;
}
ul{
  margin-top: -20px;
}
span{
  font-size: 14px;
  line-height: 16px;
  display: block;
	overflow: hidden; /*文本超出隐藏*/
	text-overflow: ellipsis; /*文本超出显示省略号*/
  width: 180px;/**范围 */
	white-space: nowrap; /*超出的空白区域不换行*/
}
.item>img{
  width: 60%;
  height: 100%;
  border-radius: 0 10px 10px 0;/**圆角 */
  float: right;
  margin-right: 18%;
}
</style>